//
//  JZHHuiFuTableViewCell.m
//  极致荟
//
//  Created by hetao on 14-7-4.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "JZHHuiFuTableViewCell.h"
#import "JZHHFView.h"
#import "JZHProductDetailsViewController.h"
@implementation JZHHuiFuTableViewCell

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)huifu:(id)sender
{
    JZHHFView *ce=[JZHHFView share];
    [ce showHFview:self.con];
    ce.okContenr=^ void(NSString *str)
    {
        JZHProductDetailsViewController *pdcon=(JZHProductDetailsViewController *)self.con;
        NSDictionary *dic=[[NSDictionary alloc] initWithObjectsAndKeys:@"topic_content",@"commentType",[NSNumber numberWithInt:[User defuceUser].userId],@"userId",[NSNumber numberWithInt: pdcon.commodity.comid],@"commentId",str,@"content",[NSNumber numberWithInt:reciew.recUser.userId],@"replyId", nil];
        [HttpRequest httpRequestPost:JZHHTTPURL(@"comment/addComment") parameters:dic block:^(id data, HttpReturnCode rerurncode) {
            
        }];
    };
}

- (CGFloat)addCellData:(JZHReview *)rev viewconteroller:(UIViewController *)con isHuiFu:(BOOL)huiFu
{
    if(huiFu)
    {
        if(rev.recUser.userId==[User defuceUser].userId)
        {
            self.huifu.hidden=YES;
        }else
        {
            self.huifu.hidden=NO;
            
        }
    }else
    {
        self.huifu.hidden=YES;
    }
    
    reciew=rev;
    self.con=con;
    self.name.text=rev.recUser.username;
    if(rev.beReplyUser)
    {
        self.comment.text=[NSString stringWithFormat:@"回复:%@ %@",rev.beReplyUser.name,rev.comment];
    }else
    {
        self.comment.text=rev.comment;
    }
    
    [ImageCache imageUrl:rev.recUser.userHeadImage UiImageview:self.headimage];
    NSDateFormatter *form=[[NSDateFormatter alloc]init];
    [form setDateFormat:@"yyyy年MM月dd日"];
    self.revdate.text=[form stringFromDate:rev.revdate];
    [self.comment sizeToFit];
    CGRect rect=self.huifu.frame;
    [self.huifu setFrame:CGRectMake(rect.origin.x, self.comment.frame.origin.y+self.comment.frame.size.height, rect.size.width, rect.size.height)];
    NSLog(@"%f",self.huifu.frame.origin.y);
    return self.huifu.frame.origin.y+rect.size.height;
}
@end
